/*
* introduction: This code is just a key-words object.
* thanks-to https://github.com/maryrosecook/littlelisp
*
* author ufo
* email ufo5260987423@163.com
* date 28 March 2014 
*
* quality Firefox 28.0 +ubuntu 12.04 accept
*/
var keyWords={
	'def': function (input, context) {
		if (input[1] instanceof Array) {
			var token = new Token('identifier','lambda');
			environment.set(input[1][0].value, this.lambda(
					[token, input[1].slice(1), input[2]], environment));
		}else
			environment.set(input[1].value, interpret(input[2], environment));
	},
	'if': function(input, context) {
		return interpret(input[1], context) ?
			interpret(input[2], context) :
			interpret(input[3], context);
	},
	'let': function (input, context) {
	 	var letScope = input[1].reduce(function (acc, input) {
				acc[input[0].value] = interpret(input[1], context);
				return acc;
			}, {});
		return interpret(input[2], new Context(letScope, context));
	},
	'lambda': function(input,context){
			return function(){
				var lambdaArguments = arguments;
				var lambdaScope = input[1].reduce(
					function(acc, x, i){
						acc[x.value] = lambdaArguments[i];
						return acc;
					}, {});
		 		return interpret(input[2], new Context(lambdaScope, context));
	 		};
		}
};
